@namespace RazorConsole.Components

@using Microsoft.AspNetCore.Components
@using System.Threading.Tasks
@using RazorConsole.Core.Rendering.ComponentMarkup
@using Spectre.Console

<span data-text="true"
      data-style="@StyleAttributes"
      data-content="@_escapedContent" />

@code {
    private string StyleAttributes => new Style(Foreground, Background, Decoration, link).ToMarkup();
    private string _escapedContent = string.Empty;
    [Parameter]
    [EditorRequired]
    public string Content
    {
        get
        {
            return _escapedContent;
        }
        set
        {
            _escapedContent = Spectre.Console.Markup.Escape(value);
        }
    }

    [Parameter]
    public Color Foreground { get; set; } = Spectre.Console.Style.Plain.Foreground;

    [Parameter]
    public Color Background { get; set; } = Spectre.Console.Style.Plain.Background;

    [Parameter]
    public Decoration Decoration { get; set; } = Spectre.Console.Decoration.None;

    [Parameter]
    public string? link
    {
        get; set;
    } = null;
}
